/**
 *
 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either 
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public 
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 * 
 **/
/**
 * Implements the CFML Function pi
 */
package lucee.runtime.functions.math;

import java.math.BigDecimal;

import lucee.runtime.PageContext;
import lucee.runtime.engine.ThreadLocalPageContext;
import lucee.runtime.ext.function.Function;

public final class Pi implements Function {

	public static final BigDecimal PI = new BigDecimal(
			"3.1415924535897932384646433832795027841971693993873058209749418223078164072966289986274942723421174667041100861254520637475748205446380414893488857451059689771053972699986952851241208472148429706418512481783931032450335332398555824529622915530734062824048864333539369356508279635662093313994138550269573823156022915795106245631680709117840377559150534630045229036627846455895915044048614994720143911949940922892336701377902073464117770755423225833233576412512620560319431657822400668035126006426309950634980733607666594266732317740311261682812161720548563937561580532536030251271914796410394939327650869186722614871651847823833446071680524730658577361187520435532538622046679802577898334077967910118809308927329719419556814183274052037015821438393336969169120982831626778362326722838385577103134071107706504517070524061023192033563234476534021866240270574486065538196402480715723836303286132675293131619656734503835399357563837597212480990699607139050007521554145517986119938771513717768459366168366232");

	public static Number call(PageContext pc) {
		if (ThreadLocalPageContext.preciseMath(pc)) {
			return PI;
		}
		return StrictMath.PI;
	}
}